package com.neusoft.acquistion.sensor.consumer.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;

import java.io.Serializable;
import java.time.LocalDateTime;


/**
 * <p>
 * 收集来自传感器的数据
 * </p>
 *
 * @author 段静迪
 * @since 2024-04-26 14:27:10
 */
@Tag(name = "Sensordata对象", description = "收集来自传感器的数据")
public class Sensordata implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema( description =  "数据流水号")
    @TableId(value = "sn", type = IdType.AUTO)
    private Long sn;

    @Schema(description =  "病人身份证号码")
    private String personid;

    private Long medicalcode;

    @Schema(description =  "监视器编号")
    private Integer sensornumber;

    @Schema(description =  "医疗数据项目名称，如：血氧")
    private String item;

    @Schema(description =  "数据采集时间，由系统默认插入")
    private LocalDateTime dt;

    @Schema(description =  "检测结果数据")
    private String data;

    public Long getSn() {
        return sn;
    }

    public void setSn(Long sn) {
        this.sn = sn;
    }

    public String getPersonid() {
        return personid;
    }

    public void setPersonid(String personid) {
        this.personid = personid;
    }

    public Long getMedicalcode() {
        return medicalcode;
    }

    public void setMedicalcode(Long medicalcode) {
        this.medicalcode = medicalcode;
    }

    public Integer getSensornumber() {
        return sensornumber;
    }

    public void setSensornumber(Integer sensornumber) {
        this.sensornumber = sensornumber;
    }

    public String getItem() {
        return item;
    }

    public void setItem(String item) {
        this.item = item;
    }

    public LocalDateTime getDt() {
        return dt;
    }

    public void setDt(LocalDateTime dt) {
        this.dt = dt;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Sensordata{" +
            "sn = " + sn +
            ", personid = " + personid +
            ", medicalcode = " + medicalcode +
            ", sensornumber = " + sensornumber +
            ", item = " + item +
            ", dt = " + dt.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) +
            ", data = " + data +
        "}";
    }

    public String toCSV() {
        return  sn +
                "," + personid +
                "," + medicalcode +
                "," + sensornumber +
                "," + dt.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))   +
                "," + item +
                "," + data ;
    }
}
